import {getCaptureImageBlob} from "../../utils/capture/capture.js";
import {dateFormatter2} from "../../utils/utils.js";
import {saveWebFile} from "../../bomb/db.file.js";


function saveImageBlob(imageBlob) {
    let dateStr = dateFormatter2(new Date());
    let fileName = `WEB截屏_${dateStr}.png`;
    const file = Bmob.File(fileName, imageBlob);
    file.save().then(res => {
        console.log(res)
        saveWebFile({
            fileType: "capture",
            fileName: fileName,
            filePath: res[0].url,
            fileSize: imageBlob.size,
            fileSizeDesc: (imageBlob.size / 1024).toFixed(2) + "KB"
        })
    })
}

function getScreenCapture() {
    getCaptureImageBlob((imageBlob) => {
        saveImageBlob(imageBlob);
    })
}

$(document).ready(() => {
    setTimeout(() => {
        getScreenCapture()
    }, 1000)
})
